<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-07-19 09:18
 *
 * Version: 2.0
 */

namespace App\Modules\Member\Repositoryies;


use App\Exceptions\NotFoundException;
use App\Models\MemberCoin;
use App\Modules\Member\Validators\MemberCoinValidator;
use Flower\Core\Repository\Eloquent\BaseRepository;
use Illuminate\Support\Facades\DB;

class MemberCoinRepository extends BaseRepository
{
	public function model()
	{
		return MemberCoin::class;
	}

	public function validator()
	{
		return MemberCoinValidator::class;
	}

	/**
	 * 预约新增县令币流水
	 * @param $memberId
	 * @param $storeId
	 * @param $coin
	 * @param $source
	 * @param $purpose
	 * @param $linkId
	 * @return mixed
	 */
	public function consumeCoin($memberId, $storeId, $coin, $source, $purpose, $linkId)
	{
		$params = [
			'member_id' => $memberId,
			'store_id'  => $storeId,
			'coin'      => $coin,
			'coin_date' => time(),
			'source'    => $source,
			'purpose'   => $purpose,
			'link_id'   => $linkId
		];

		return $this->create($params);
	}
}